import http from '@/plugins/aixos'

export function addZone(zone: ZoneModel) {
  return http.request({
    url: '/zone',
    method: 'POST',
    data: zone,
  })
}

export function findAllZone(args: Record<string, any>) {
  const url =
    '/zone?' +
    Object.entries(args)
      .map(([key, value]) => `${key}=${value}`)
      .join('&')
  return http.request<ZoneModel[]>({
    url,
    method: 'GET',
  })
}

export function delZone(id: number) {
  return http.request<ResponseModel<ZoneModel>>({
    url: `/zone/${id}`,
    method: 'DELETE',
  })
}

export function updateZone(id: number, zone: Partial<ZoneModel>) {
  return http.request({
    url: `/zone/${id}`,
    method: 'PATCH',
    data: zone,
  })
}

export function findZone(id: number) {
  return http.request<ZoneViewModel>({
    url: `/zone/${id}`,
    method: 'GET',
  })
}
